<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="javax.jdo.PersistenceManager"%>
<%@page import="cn._2dland.access.jdo.*"%>
<%
	/*
	User user = (User)session.getAttribute("LoginUser");
	if(user == null) response.sendRedirect("/admin/login.jsp");
	*/

	String userName = request.getParameter("username");
	String userType = request.getParameter("usertype");
	String password = request.getParameter("password");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>新增视频</title>
	<link rel="stylesheet" type="text/css" href="/style/style.css">
</head>
<body>
	<script type="text/javascript">
<%
	PersistenceManager pm = null;
	try {
		if(userName == null || password == null) throw new Exception("参数不完整！");
		Integer type = Integer.valueOf(userType, 10);
		User user = new User(userName, password, type);
		pm = PMFactory.getPMFInstance().getPersistenceManager();
		pm.makePersistent(user);
%>
		alert('用户添加成功！');
		window.close();
<%
	}
	catch (Exception e) {
		e.printStackTrace();
%>
		window.alert('用户添加失败！');
		history.back();
<%
	}
	finally {
		if(pm != null) pm.close();
	}
%>
	</script>
</body>
</html>